<?php

namespace App\Exports;

use App\Models\Question;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;

class TestListExport implements FromArray,WithHeadings,ShouldAutoSize
{

    use Exportable;

    private $testList, $type;

    public function __construct($testList, $type)
    {
        $this->testList = $testList;
        $this->type = $type;
    }

    public function array(): array
    {
        return testQuestion($this->testList,$this->type);
    }

    public function headings(): array
    {
        // TODO: Implement headings() method.
        if ($this->type == 1){
            return [
                'id',
                '标题',
                '题干',
                '所有答案',
                '正确答案',
                '题目分数',
                '',
                '题目类型',
            ];
        }else{
            return [
                'id',
                '标题',
                '题干',
                '题目分数',
                '',
                '题目类型',
            ];
        }
    }
}
